#pragma once
#include "parser_list.h"
#include <stdexcept>

namespace krryn{
namespace scene{
	class scene_graph;
	class scene_graph_node_base;

	class node_not_found : public std::runtime_error{
	public:
		node_not_found(const std::string &a_Message) : runtime_error(a_Message) {}
		virtual ~node_not_found() throw() {}
	};

	class required_property_not_found : public std::runtime_error{
	public:
		required_property_not_found(const std::string &a_NodeName, const std::string &a_Property) 
			: runtime_error(std::string("Missing ") + a_NodeName + std::string(" in ") + a_Property) {}

		virtual ~required_property_not_found() throw() {}
	};

	class scene_graph_loader : public parsers::parser_list_action{
	public:
		scene_graph_loader();

		virtual void accept(parsers::parser_list_node *a_Node);
		scene_graph *get_scene_graph();
	private:
		void validate(parsers::parser_list_node *a_Node, const std::string &a_Property) const;
		std::vector<std::string> *get(parsers::parser_list_node *a_Node, const std::string &a_Property) const;
		scene_graph *m_Root;
		scene_graph_node_base *m_Current;
	};
}
}
